package com.platform.server.util;

import java.net.HttpURLConnection;
import java.net.URL;

public class URLConnection {

	public static HttpURLConnection getConnection(String url){
		HttpURLConnection connection = null;
		try {
			URL postUrl = new URL(url);
			// 打开连接
			connection = (HttpURLConnection) postUrl
					.openConnection();
			connection.setConnectTimeout(5000);
			connection.setReadTimeout(100000);
			connection.setDoOutput(true);
			connection.setDoInput(true);
			connection.setRequestMethod("POST");
			connection.setUseCaches(false);
			connection.setInstanceFollowRedirects(true);
			connection.setRequestProperty("Content-Type", "application/json");
			connection.setRequestProperty("Charset", "utf-8");
			connection.setRequestProperty("Accept-Charset", "utf-8");
		} catch (Exception e) {
			e.printStackTrace();
		} 
		return connection;
	}
}
